package com.example.websocket.redis.config;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.ObjectRecord;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

//@Component
public class RedisGroupStreamService {

    @Autowired
    private StringRedisTemplate redisTemplate;
    

    /**
       * 发送消息，初始化微信菜单，行业，模板消息的数据
     * @param data
     */
    public void sendEvent(Map<String, Object> data) {
        RedisGroupEvent event = new RedisGroupEvent("redis-test", data, System.currentTimeMillis());
        ObjectRecord<String, RedisGroupEvent> record = StreamRecords.objectBacked(event).withStreamKey("test");
        redisTemplate.opsForStream().add(record);
    }

}
